class DrugController < ApplicationController
  
  def list_with_initial
    @current_initial = params[:id]    
    @drugs_with_initial = Drug.with_prefix(@current_initial)
    @page_title = "#{@current_initial} Drugs"
    @is_show_category_initials = false
  end
  
  def show
    @drug = Drug.find(params[:id])
    @score = @drug.average_score
    @categories = @drug.categories
    @total_ratings_number = @drug.ratings_number
    @filtered_ratings_number = @total_ratings_number
    @filtered_sideffects = @drug.sideffects
    @total_sideffects_number = @filtered_sideffects.size
    @sex_stats = @drug.sex_stats
    @age_stats = @drug.age_stats
    @time_taken_stats = @drug.time_taken_stats
    @page_title = @drug.name
    @is_show_category_initials = false
  end
  
  def filter_sideffects
    drug = Drug.find(params[:id])
    @filtered_ratings_number = drug.ratings_number(params)
    @filtered_sideffects = drug.sideffects(params)
    render :partial => "drug_sideffects", :layout => false
  end
end
